<template>
  <div>
           <van-nav-bar title="用户">
  <template #right>
    <van-icon name="search" size="18" />
  </template>
</van-nav-bar>

<div class="lop">
<van-image
  round
  width="6rem"
  height="6rem"
  src="https://img.yzcdn.cn/vant/cat.jpeg"
/>
<p>{{username}}</p> 
</div>

<van-button width="100px" v-if="state" @click="tui" type="primary" block>请登录</van-button>
<van-button width="100px" v-if="ti" @click="tui" type="primary" color="red" block>退出登录</van-button>


<van-cell title="地址管理" icon="cart-o" is-link/>
<van-cell title="收藏管理" icon="cart-o"/>
  </div>
</template>

<script>
export default {
  created(){
    if(localStorage.getItem("userInfo2")){
     this.get()
    }
  },
data(){
return{
state:true,
ti:false,
username:"请登录"
}
},
methods:{
  tui(){
  this.$router.push("/login")
  },
get(){
this.state=false
this.ti=true
this.username=JSON.parse(localStorage.getItem("userInfo2")).nickname
}
}
}
</script>

<style>
.lop{
  margin: 20px 0 20px 136px;
}
p{
  margin-left: 18px;
}
</style>